package com.guigu.www.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.guigu.www.pojo.*;
import com.guigu.www.service.TBodyTypeService;
import com.guigu.www.service.TMentalityResultService;
import com.guigu.www.service.TQuestionAnwserService;
import com.guigu.www.service.TQuestionBankService;
import com.guigu.www.service.impl.TMentalityResultServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yb
 * @since 2021-06-18
 */
@RestController
@CrossOrigin
public class TQuestionAnwserController {

    @Autowired
    private TQuestionAnwserService service;

    @Autowired
    private TBodyTypeService tBodyTypeService;

    @Autowired
    private TMentalityResultService tMentalityResultService;

    @PostMapping("selanwser")
    public Question selanwser(@RequestBody TQuestionAnwser tQuestionAnwser){
        return service.selanwser(tQuestionAnwser);
    }





    @PostMapping("selanwser2")
    public Question selanwser2(@RequestBody TQuestionAnwser tQuestionAnwser){
        return service.selanwser2(tQuestionAnwser);
    }




    @PostMapping("addanwser")
    public void addanwser(@RequestBody Question tQuestionAnwsers){
        int huiyuaid = tQuestionAnwsers.getHuiyuaid();
        TBodyType tBodyType=new TBodyType();
        tBodyType.setTMemberId(huiyuaid);
        int a1=0;

        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getPhz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a1=tQuestionAnwser.getAnwser()+a1;
            if(a1>6){
                 tBodyType.setTPhz(0);
            }else{
                tBodyType.setTPhz(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a2=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getQxz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a2=tQuestionAnwser.getAnwser()+a2;
            if(a2>6){
                tBodyType.setTQiAsthenia(0);
            }else {
                tBodyType.setTQiAsthenia(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a3=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getYingxz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a3=tQuestionAnwser.getAnwser()+a3;
            if(a3>6){
                tBodyType.setTYinDeficiency(0);
            }else {
                tBodyType.setTYinDeficiency(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a4=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getYangxz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a4=tQuestionAnwser.getAnwser()+a4;
            if(a4>6){
                tBodyType.setTYangQuality(0);
            }else {
                tBodyType.setTYangQuality(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a5=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getTsz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a5=tQuestionAnwser.getAnwser()+a5;
            if(a5>6){
                tBodyType.setTTsz(0);
            }else {
                tBodyType.setTTsz(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a6=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getSrz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a6=tQuestionAnwser.getAnwser()+a6;
            if(a6>6){
                tBodyType.setTSrz(0);
            }else {
                tBodyType.setTSrz(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a7=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getXyz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a7=tQuestionAnwser.getAnwser()+a7;
            if(a7>6){
                tBodyType.setTXyz(0);
            }else {
                tBodyType.setTXyz(1);
            }
            service.addanwser(tQuestionAnwser1);

        }

        int a8=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getQyz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a8=tQuestionAnwser.getAnwser()+a8;
            if(a8>6){
                tBodyType.setTQyz(0);
            }else {
                tBodyType.setTQyz(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a9=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getTbz()) {
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a9 = tQuestionAnwser.getAnwser() + a9;
            if (a9 > 6) {
                tBodyType.setTTbz(0);
            } else {
                tBodyType.setTTbz(1);
            }
            service.addanwser(tQuestionAnwser1);
        }
        tBodyTypeService.addISok1(tBodyType);
    }



    @PostMapping("addanwser2")
    public void addanwser2(@RequestBody Question tQuestionAnwsers){
        int huiyuaid = tQuestionAnwsers.getHuiyuaid();
        TMentalityResult tMentalityResult=new TMentalityResult();
        tMentalityResult.setTMemberId(huiyuaid);
        int a1=0;

        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getQth()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a1=tQuestionAnwser.getAnwser()+a1;
            if(a1>6){
                tMentalityResult.setTQth(0);
            }else{
                tMentalityResult.setTQth(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a2=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getQpzh()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a2=tQuestionAnwser.getAnwser()+a2;
            if(a2>6){
                tMentalityResult.setTOcd(0);
            }else {
                tMentalityResult.setTOcd(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a3=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getRjgx()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a3=tQuestionAnwser.getAnwser()+a3;
            if(a3>6){
                tMentalityResult.setTRjgx(0);
            }else {
                tMentalityResult.setTRjgx(1);
            }
            service.addanwser(tQuestionAnwser1);
        }


        int a4=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getYy()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a4=tQuestionAnwser.getAnwser()+a4;
            if(a4>6){
                tMentalityResult.setTYyu(0);
            }else {
                tMentalityResult.setTYyu(1);
            }
            service.addanwser(tQuestionAnwser1);
        }



        int a5=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getJl()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a5=tQuestionAnwser.getAnwser()+a5;
            if(a5>6){
                tMentalityResult.setTAnxiety(0);
            }else {
                tMentalityResult.setTAnxiety(1);
            }
            service.addanwser(tQuestionAnwser1);
        }


        int a6=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getDd()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a6=tQuestionAnwser.getAnwser()+a6;
            if(a6>6){
                tMentalityResult.setTDdui(0);
            }else {
                tMentalityResult.setTDdui(1);
            }
            service.addanwser(tQuestionAnwser1);
        }


        int a7=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getKb()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a7=tQuestionAnwser.getAnwser()+a7;
            if(a7>6){
                tMentalityResult.setTTerror(0);
            }else {
                tMentalityResult.setTTerror(1);
            }
            service.addanwser(tQuestionAnwser1);

        }


        int a8=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getPz()){
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a8=tQuestionAnwser.getAnwser()+a8;
            if(a8>6){
                tMentalityResult.setTPzhi(0);
            }else {
                tMentalityResult.setTPzhi(1);
            }
            service.addanwser(tQuestionAnwser1);
        }

        int a9=0;
        for (TQuestionAnwser tQuestionAnwser:tQuestionAnwsers.getJsbx()) {
            TQuestionAnwser tQuestionAnwser1 = tQuestionAnwser.setTMemberId(huiyuaid);
            a9 = tQuestionAnwser.getAnwser() + a9;
            if (a9 > 6) {
                tMentalityResult.setTJsb(0);
            } else {
                tMentalityResult.setTJsb(1);
            }
            service.addanwser(tQuestionAnwser1);
        }
        tMentalityResultService.addtr(tMentalityResult);
    }

    @PostMapping("selbody")
    public TBodyType selbody(@RequestBody TBodyType tMemberId){

        return  tBodyTypeService.selbody(tMemberId) ;
    }

    @PostMapping("seltmresule")
    public TMentalityResult seltmresule(@RequestBody TMentalityResult tMemberId){
        return tMentalityResultService.seltmresule(tMemberId) ;

    }
}

